Comments (22)
With some pictures attached it will be clearer.
As I said, that issue doesn't happen with other fonts.
from bgrabitmap.
Indeed, it seems there is a problem with the size of the font. Is the code browsable on Git?
from bgrabitmap.
Thank you for your answer. The source code of the Lazarus project is included in the ZIP archive.
from bgrabitmap.
Ok. Where in the code do you prepare the images?
from bgrabitmap.
Here?
LContour := TBGRABitmap.Create(CSize, CSize, BGRAPixelTransparent);
LShader := TPhongShading.Create;
LRenderer := TBGRAFreeTypeFontRenderer.Create(LShader, True);
LRenderer.ShadowVisible := True;
LContour.FontRenderer := LRenderer;
LContour.FontName := CFonts[LFont].name;
LContour.FontFullHeight := CSize;
LContour.FontQuality := fqFineClearTypeRGB;
from bgrabitmap.
OK, I found.
//LContour.FontFullHeight := CSize;
LContour.FontHeight := CSize;
But I wonder why the problem didn't happen with other fonts.
What is the difference between FontFullHeight and FontHeight?
from bgrabitmap.
No, there is still a problem (and still no problem with other fonts).
from bgrabitmap.
FontHeight or FontEmHeight are the size of the letters themselves (it used to be the width of the letter M but not always anymore). That's the size the is shown in most text editors.
FontFullHeight is the total height the text line, including all vertical spacing.
For a given font, it is more reliable to set the FontEmHeight because the line spacing may vary depending on the font engine. Though such as size will not give the same letter size among different fonts. Conversely if you're interesting in fitting the text vertically, FontFullHeight will be more reliable, though the spacing may be too large in some cases.
Can you tell me where in the files I can find both the shaded version and the non shaded version, so that I can compare?
from bgrabitmap.
Thank you for the explanation.
chessimage1.zip is the non shaded version. chessimage2.zip is the shaded version.
from bgrabitmap.
Yeah but more specifically, what file and what line?
from bgrabitmap.
For the project chessimage1, please see chessimage.lpr, line 71:
contour := TBGRABitmap.Create(CSize, CSize, BGRAPixelTransparent);
contour.FontName := CFonts[font].name;
contour.FontHeight := CSize;
contour.TextOut(0, 0, CTable[i, CFonts[font].index], BGRABlack);
For the project chessimage2, please see chessimage_u.pas, line 124:
LContour := TBGRABitmap.Create(CSize, CSize, BGRAPixelTransparent);
LShader := TPhongShading.Create;
LRenderer := TBGRAFreeTypeFontRenderer.Create(LShader, True);
LRenderer.ShadowVisible := True;
LContour.FontRenderer := LRenderer;
LContour.FontName := CFonts[LFont].name;
//LContour.FontFullHeight := CSize;
LContour.FontHeight := CSize;
LContour.FontQuality := fqFineClearTypeRGB;
from bgrabitmap.
Ok so in theory that should be the same.
from bgrabitmap.
Ok so in theory that should be the same.
Yes, that's why I don't understand. But I don't want to bore you with that. There is no emergency. I was curious to understand what happens.
Regards.
Roland
from bgrabitmap.
I will look more closely when I can.
Regards
from bgrabitmap.
Thank you.
from bgrabitmap.
Hello, it seems that Montreal font has not a well-defined size. When I open it in a font viewer it goes outside of the line.
Though I am not sure why this would be handled differently.
Regarding the FontFullHeight / FontEmHeight, in the cases of chess font, it seems that they use the whole line, so that it does not really matter which one to use. Though I would suggest to use the same anyway in all cases.
I cannot compile the chessimage2 so I cannot debug the program. I get a linking problem.
I noticed that in one case you use BGRABitmapPack4NoGui and not in the other. I suggest you try to incorporate the effect in the chessimage1 (by setting a boolean for example) so that there is minimal difference when comparing.
Regards
from bgrabitmap.
Hello! Thank you for your answer. OK, I will say what you suggest. I come back as soon as it made.
Regards.
Roland
from bgrabitmap.
Here is chessimage2 modified.
[link deleted]
I didn't include the fonts directory. Please use the fonts from the previous package.
As you will see, the problem is still here.
Thank you for your kind assistance.
Regards.
Roland
from bgrabitmap.
Ok, so. In fact, the original problem was due to the font full height difference. Because the glyphs are oversized relative to the line size, using the full height will make the letters bigger. Thus it overflows on both right and bottom.
Using the em height solves the size problem. But now there is another problem which is that the rendering is clipped. The glyph is rendered up to the line limit. The reason is that the text effect is computed in a temporary bitmap which has the size of the text line.
To sum up, the font is not well defined, and the limitations of the text engine gives this result. One might improve that a bit, by using the actual glyph size to determine the size of the temporary bitmap and at the same time restrict that to the clipping rectangle of the destination bitmap.
That may be a bit of work, so I am not going to do that now. Maybe in the future. In particular, this might be necessary when using very big size of letters. As of now, using huge letters will create a huge temporary bitmap even though only a small portion will be visible in the destination bitmap.
from bgrabitmap.
Thank you. All is clear now.
I don't know if I should close the issue or not, so I let you do. See you soon!
Regards.
Roland
from bgrabitmap.
If you don't mind, I will remove the ZIP files from my Google Drive and delete the links in the discussion, because Chess Montreal isn't supposed to be freely distributed. So please keep a copy of it if you want to experiment.
Regards.
Roland
from bgrabitmap.
Ok no problemo.
from bgrabitmap.
Related Issues (20)
- BGRABitmap and FPC 3.2-fixes HOT 5
- compile error on bgrapixel.inc HOT 5
- Maintain the "bit format" of a file between reading and subsequent writing HOT 5
- Error: Duplicate identifier "FResolutionUnit" HOT 4
- Cannot compile package BGRABitmapPack 11.5.8 HOT 4
- Avoid WideString, use UnicodeString HOT 3
- libwebp.pas fails to compile if -Mobjfpc was not used at compilation. HOT 1
- Draw image center/cover no-repeat HOT 3
- Compile error with new visibility check on FPC trunk. HOT 1
- Function 'round' causing problems HOT 17
- libavif.pas fails to compile (mode Delphi) HOT 4
- crash on loading WEBP image on Windows-10 x64 (32bit EXE) when no DLL file is present (it must show nice msg about missing DLL) HOT 12
- -dBGRABITMAP_CORE and Canvas2D HOT 2
- Gradient text and last version 11.6. HOT 3
- Inconsistent kerning of TextSize HOT 1
- Can't close a Form after using draw() onto a TImage.Canvas HOT 3
- Support Inkscape Filters HOT 7
- Add line spacing setting
- Lazarus 3.2 and fpc 3.2.2 HOT 2
- BGRABitmapPack pulls too many libraries HOT 23
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bgrabitmap.