SourceForge logo
SourceForge logo
Menu

Re: [matplotlib-devel] dpi-related positioning errors in Agg savefig

From: Michael D. <md...@st...> - 2008年04月28日 20:37:05
John Hunter wrote:
> On Sun, Apr 27, 2008 at 3:14 AM, Eric Firing <ef...@ha...> wrote:
>
> 
>> 1) The hline generated by frac is too long with dpi=50.
>> 
>
> The problem with the hline appears to be that the width of the line in
> the frac has a component that depends on the thickness
>
> thickness = state.font_output.get_underline_thickness(
> state.font, state.fontsize, state.dpi)
> width = max(num.width, den.width) + thickness * 10.
>
> and get_underline_thickness here is defaulting to 1.0 because of this
> max call in get_underline_thickness
>
> return max(1.0, cached_font.font.underline_thickness / 64.0 /
> fontsize * 10.0)
> 
I believe that this is where the dpi needs to be factored in. Ft2font 
(well, freetype, really) seems to scale metrics for individual glyphs by 
dpi, but not the font-global metrics. I had wrongly assumed they were 
all scaled by dpi. So this is a subtler instance of the recent x-height 
bug that caused sub/superscripts to be incorrect at different dpi's.
> Michael -- what is the role of these 10.0 scale factors, which is
> showing up in both the frac call and the get_underline_thickness? Is
> this something from Knuth, or is it a fudge factor that gets it mostly
> right? I suspect we will need something like
>
> width = max(num.width, den.width) + thickness * 10. * state.dpi/72.
> 
This 10.0 is from Knuth. It is the amount of overhang of the fraction 
beam, and is meant to be relative to the thickness of the beam itself. 
The other 10.0 (in get_underline_thickness) is my own experimental fudge 
to deal with the peculiarities of how underline thickness is stored in 
Truetype fonts. (Remember "pure" TeX uses a completely different font 
metric standard, so some mapping from TrueType/freetype etc. had to be 
fudged on.)
What's causing the fraction bar to be too wide at lower dpi is the 
minimum underline thickness of 1.0 enforced in get_underline_thickness. 
I think that was a mistake -- enforcing 1.0 pixel lines should happen 
closer to the backend level -- so I've removed the max(1.0, ...) there.
> but with this change the frac bar looks a little too wide -- which is
> why I'm wondering if there is something magic about 10. or if another
> number might serve better.
> 
-- 
Michael Droettboom
Science Software Branch
Operations and Engineering Division
Space Telescope Science Institute
Operated by AURA for NASA

View entire thread

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.
Thanks for helping keep SourceForge clean.
X





Briefly describe the problem (required):
Upload screenshot of ad (required):
Select a file, or drag & drop file here.
Screenshot instructions:

Click URL instructions:
Right-click on the ad, choose "Copy Link", then paste here →
(This may not be possible with some types of ads)

More information about our ad policies

Ad destination/click URL:

AltStyle によって変換されたページ (->オリジナル) /