Opened 3 years ago

Last modified 2 years ago

#17523 new bug

Incorrect right edge is reported for the characer "U" under Noto Sans Display Italic

Reported by: hgsfghs Owned by: nobody
Priority: normal Milestone: Unscheduled
Component: Kits/Interface Kit Version: R1/beta3
Keywords: Cc:
Blocked By: Blocking:
Platform: All

Description (last modified by hgsfghs)

Run the following code:

    BFont ft;
    ft.SetSize (52);
    ft.SetFamilyAndStyle ("Noto Sans Display", "Italic");
    const char *str = "U";
    float fl;
    edge_info ei;
    ft.GetEscapements (str, strlen (str), (float *) &fl);
    ft.GetEdges (str, strlen (str), (edge_info *) &ei);
    vw->LockLooper ();
    vw->SetHighColor (128, 0, 255, 255);
    vw->SetPenSize (1.0);
    vw->StrokeRect (BRect (0, 0, (ei.right + fl) * ft.Size (), 30));
    vw->MovePenTo (0, 50);
    vw->SetFont (&ft);
    vw->SetHighColor (128, 255, 255, 0);
    vw->DrawString (str);
    vw->UnlockLooper ();

The cyan text will draw outside the purple rectangle, which is incorrect, since the escapement + right edge should be the right-most pixel that is drawn onto the display.

Thanks.

This happens on R1/Beta3 and also a nightly built from hrev55768. Sorry for not specifying that when creating the ticket, but I don't know how to edit that information after a ticket has been submitted.

Change History (4)

comment:1 by hgsfghs, 3 years ago

Description: modified (diff)

comment:2 by pulkomandy, 3 years ago

These APIs can't be used in this way because hinting changes the shape and size of the characters.

If you really need this, you will need to set the font spacing to B_CHAR_SPACING, and I'm not sure even that wild be enough.

You will get more reliable results from StringWidth or GetBoundingBoxesAsString, which work in display resolution and will handle the hinting as correctly as possible

comment:3 by hgsfghs, 3 years ago

Hmm, thanks, but I'm not exactly sure how to find the origin (left escapement boundary) of a glyph from a bounding box.

Any ideas?

comment:4 by waddlesplash, 2 years ago

Component: - GeneralKits/Interface Kit
Note: See TracTickets for help on using tickets.