-
Notifications
You must be signed in to change notification settings - Fork 40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Scaling affects layout #450
Comments
The example can be changed to add just one BlTextElement like this: space root addChild:
(BlTextElement new
text: ((' ' join: (Array new: 5 withAll: 'Bloc')) asRopedText
fontSize: 40;
yourself);
yourself). Then the text in the two windows does not have the same width: That is unexpected to me, see Pharo pull request #14503 for comparison. |
Hello @Rinzwind I reproduced your commit changes in my image and see same weird results. I will dig more and come back |
OK! There are some other changes you may need to apply, the pull request hasn’t been merged yet: Pharo pull request #16225. It fixes this error when a ScalingCanvas scales a BlExternalForm: |
Thanks, I applied your change. I am not sure why I didn't need it, it may be because I tested it with scale factor = 1. But now I applied your change in OSSDL2ExternalForm>>magnifyBy:smoothing: |
Aha! I've checked what happens at the low-level of just plain Cairo+Freetype, and it is related to text hinting, in font options. The difference vanishes when I changed (BTW, the criteria to set either "low" or "high" quality from Bloc in the AeCanvas can be revisited.) |
Hinting can be enabled for rendering (AeCairoFontOptions>>hintStyle:) and disabled for calculating metrics (AeCairoFontOptions>>hintMetrics:), i.e. the set of a text extents. Freetype library document about hinting: https://freetype.org/freetype2/docs/hinting/subpixel-hinting.html FYI, inspect: fontSize := 45.
string := 'Bloc'.
surfaceSize := 100 @ 50.
fontOptions :=
AeCairoFontOptions new
hintMetrics: AeCairoHintMetrics off;
hintStyle: AeCairoHintStyle full;
yourself.
#(0.5 0.75 1.0 2.0 3.0 10.0) collect: [ :scale |
| aSurface aContext aFTLibrary aFTFace aScaledFont |
aSurface := AeCairoImageSurface
extent: surfaceSize * scale
format: AeCairoSurfaceFormat argb32.
aSurface deviceScaleX: scale y: scale.
aContext := aSurface newContext.
"Set up scaled font in the context"
aFTLibrary := AeFTLibrary newInitialized.
aFTFace := AeSourceSansPro_Bold firstFaceUsing: aFTLibrary.
aContext
fontFace: aFTFace newCairoFontFace;
fontSize: fontSize;
fontOptions: fontOptions.
aScaledFont := aContext scaledFont.
glyphs := aScaledFont glyphArrayForString: string.
"Draw text"
aContext
translateByX: 5 y: fontSize;
sourceColor: Color black;
showGlyphs: glyphs.
{scale. aScaledFont fontExtents. aScaledFont glyphExtentsOf: glyphs. aSurface } ]. With |
Ah OK, I see there’s a comment about that on AeCairoHintMetrics as well: “Specifies whether to hint font metrics; hinting font metrics means quantizing them so that they are integer values in device space. Doing this improves the consistency of letter and line spacing, however it also means that text will be laid out differently at different zoom factors.” So would it be better to change |
I think we can set both low and high quality use In another issue we can discuss if we either remove or improve the heuristic in
|
…ting, as is done in #setLowQualityOptions, to avoid text being laid out differently at different scale factors (see: pharo-graphics/Bloc#450).
OK, I have opened Alexandrie pull request #51 to change |
I think this can be closed. The two pull requests have been merged. |
In Roassal pull request #56 I made RSAthensMorph apply the world renderer canvas scale factor. I now tried to do the same for BlMorphicHost: commit 3db44c8.
That however has an effect that I didn’t expect in the following example (based on the one opened by doing
BlMorphicHost example
):The layout is different in the two windows:
Is this a bug in Bloc or am I just making a mistake?
The text was updated successfully, but these errors were encountered: