Code Monkey home page Code Monkey logo

Comments (22)

rchastain avatar rchastain commented on May 30, 2024

With some pictures attached it will be clearer.

bb
bb

As I said, that issue doesn't happen with other fonts.

from bgrabitmap.

circular17 avatar circular17 commented on May 30, 2024

Indeed, it seems there is a problem with the size of the font. Is the code browsable on Git?

from bgrabitmap.

rchastain avatar rchastain commented on May 30, 2024

Thank you for your answer. The source code of the Lazarus project is included in the ZIP archive.

from bgrabitmap.

circular17 avatar circular17 commented on May 30, 2024

Ok. Where in the code do you prepare the images?

from bgrabitmap.

rchastain avatar rchastain commented on May 30, 2024

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.

rchastain avatar rchastain commented on May 30, 2024

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.

rchastain avatar rchastain commented on May 30, 2024

No, there is still a problem (and still no problem with other fonts).
bk

from bgrabitmap.

circular17 avatar circular17 commented on May 30, 2024

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.

rchastain avatar rchastain commented on May 30, 2024

Thank you for the explanation.
chessimage1.zip is the non shaded version. chessimage2.zip is the shaded version.

from bgrabitmap.

circular17 avatar circular17 commented on May 30, 2024

Yeah but more specifically, what file and what line?

from bgrabitmap.

rchastain avatar rchastain commented on May 30, 2024

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.

circular17 avatar circular17 commented on May 30, 2024

Ok so in theory that should be the same.

from bgrabitmap.

rchastain avatar rchastain commented on May 30, 2024

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.

circular17 avatar circular17 commented on May 30, 2024

I will look more closely when I can.

Regards

from bgrabitmap.

rchastain avatar rchastain commented on May 30, 2024

Thank you.

from bgrabitmap.

circular17 avatar circular17 commented on May 30, 2024

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.

rchastain avatar rchastain commented on May 30, 2024

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.

rchastain avatar rchastain commented on May 30, 2024

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.

circular17 avatar circular17 commented on May 30, 2024

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.

rchastain avatar rchastain commented on May 30, 2024

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.

rchastain avatar rchastain commented on May 30, 2024

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.

circular17 avatar circular17 commented on May 30, 2024

Ok no problemo.

from bgrabitmap.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.