-
Notifications
You must be signed in to change notification settings - Fork 39
Updated documentation for label.py to clarify usage for background #75
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
Comments
Sorry it took me a bit until I got back to this. I think this is a good place to coordinate for now. Other folks can chime in if they have idea's and we'll close the issue once the edits to the guide pages are complete. There is a learn guide repo but it contains mostly projects and sample code used in learn guides. Not the content of the guide pages. These all look like they'd be great additions to the current guide pages. I will work on making some minimal sample code to illustrate the background size options and get some screenshots taken so we can show examples of how they different options affect the look. I can get make images illustrating how the origin point works with multi-line text strings while I'm at it. |
@FoamyGuy I was looking into @kmatch98 description and the examples that he mentions here. taking into account the work being done in https://github.com/adafruit/Adafruit_CircuitPython_DisplayIO_Layout/issues/3 |
@jposada202020 I am definitely on board with that idea. One thing that would be great is adding a few more examples that will illustrate some of the features that are less documented. We can use screenshots from those examples in the guide page once it gets created. Perhaps this example: https://github.com/adafruit/Adafruit_CircuitPython_Display_Text/blob/master/examples/display_text_background_color_padding.py could be modified a bit to illustrate the usage of background_tight and padding values. The code in there now is essentially a test case that we noticed a bug with at some point. It's a tad more of a test that proves the bug is fixed rather than an example meant to show how to use something as is. |
For completeness, I thought I would add a few more text-related items to the features that need documentation. I don’t have any experience with editing learn guides but let me know if you want any contribution from my end. Since the issue was raised above, @FoamyGuy and @jepler have added several other features:
|
All really great suggestions! Thank you @kmatch98 I have access and experience modifying the learn guides so I can go in and make those final edits when we are ready to do them. I think the best way to collaborate on it will be working on examples and writing into txt or md files for now. Those can be checked in to a branch somewhere that we can all see, or posted on threads like this one. Then when it's finalized I can go in and put it into the actual guides system. I think we want to try to get at least one example that illustrates each feature. That way we can include screenshots of them in the guide, and embed the github code links to those examples in the guides. |
Good, I worked already in the examples to illustrate the following:
Based on |
@jposada202020 Awesome! Thank you for working on this. Check out BitmapSaver library if you haven't already for saving screenshots: https://github.com/adafruit/Adafruit_CircuitPython_BitmapSaver My PyGameDisplay driver is good for screenshots as well on PC, but does require a bit more setup |
Thanks @FoamyGuy I have alread done the setup with your PyGameDisplay driver. I will use that one. |
@FoamyGuy @kmatch98 Included the proposal for the guide/doc, I just want to go too far into this if this is not good. Let me know if this make any sense. Also, in doing this, I have a proposal to change the library to solve issues #100 and #103. The proposal will add a new parameter call yoffset that will mask/unmask the offset value calculated with get_ascend_descend function and probably let us solve those issue, it will need some tinkering for the background box as this value is also used there. Label change proposal and Code example are here Label LibraryThe label library allows us to publish certain text into a display. There are different label parameters that allow us to set up the font, position, background characteristics among others. Label positionThere are different ways to set up the label position in the display. This includes:
x, y coordinatesx, y coordinates allows to define the label position. When setting text location using the x and y properties, you are setting the Anchor PointsThe anchor_point property of the label is a (x, y) tuple. The values range from 0 to 1 with x being the horizontal and y being the vertical. The origin is in the upper left corner. A value of 0 is at the origin. A value of 1 is all the way to the right/down. Anchor PositionThe label position on the display could be located using the anchored_position property. TileGrid PositionWhen you create a text label, the library will create an imaginary box that encloses all the glyphs in the text. All the glyphs AscendIs a value in pixels of the upper portion that extends from the median of a particular glyph DescendIs a value in pixels of the bottom portion that extends from the median of a particular glyph Advanced text positioningLabel text positioning is calculated inside the private function
Positioning in the y-axis is calculated as follows:
Label BackgroundLabel background is an imaginary box that enclose the label. We can define the color and size of this box to create different cool effects.
###Background tight ###Padding Other TopicsBuiltin FontWhen a font is not specified in Label parameters, CircuitPython uses the default font builtin. This is included in the core library fontio.
Optimize Font File Size (Manually)You could use a text editor to remove glyphs from a .bdf file. BDF files are just text! Open a BDF file and search for “asciitilde” — this is usually the highest plain-ASCII-value glyph we want to preserve. A few lines down there will be an “ENDCHAR” line. Delete everything after the ENDCHAR line, then add a line containing ENDFONT. That’s it! Save the file, which is usually just a small fraction of the original size. You won’t get any accented characters or special punctuation this way, so it’s not always the right thing for every situation. For the |
On first read through all of this looks great! Thanks for taking the time to get this out @jposada202020. Over the weekend I'll take a deeper dive into this and start moving it into a draft page in the learn guide so we can get some feedback from kattni and/or anne. |
This is just a note to remind to include in the new documentation some mention regarding the Base alignment after discussion in discord. Also it would be a good to explain to people the space distance. |
I review the box and update the text |
The new guide for display_text library went live today! https://learn.adafruit.com/circuitpython-display_text-library |
Super awesome. @FoamyGuy and @jposada202020 thanks for all your additions and documentation to make this even more useful for folks! |
@FoamyGuy Amazing guide. Nice graphics!!! and very detailed explanations, every possible parameter was described and account for. Excelent work here! |
yes! its great, good work :) |
Uh oh!
There was an error while loading. Please reload this page.
@FoamyGuy Here are my collection of thoughts on updates for the learn guide for
adafruit_display_text\label.py
. I just realized that maybe this belongs in a separate repository with the learn guides, but I couldn't identify the location. If you know an alternate location, let me know. If you have time to review this list, please add your suggestions and then we can discuss how you want to coordinate or divvy-up any work on the learn guide.Documentation updates:
Briefly describe differences in font typefaces: Fixed width vs variable width (proportional). We can handle both! Explain that
BuiltinFont
'sterminalio.FONT
can be used with a TileGrid resource-efficiently since it is a fixed-size font. (There is an open issue over in circuitpython about using TileGrid withBuiltinFont
(issue Add TileGrid example that uses the built in font to display text circuitpython#2566.)Define the baseline position (halfway up the M glyph). There is already an image in the current learn guide. Indicate that is is mostly important if you are formatting multiple lines of text and they need to align. Define ascenders/descenders, since this useful for understanding the background options.
anchor_point
andanchor_position
: reference the candy hearts exampleExplain background size options:
background_tight = False
(default): Background dimensions include room for ascenders and descenders for the font, even if the text does not have any ascenders/descenders. [Note: Ascenders and descender dimensions are sampled from these letters: M, j, ' (apostrophe)]background_tight = True
: Background dimensions are set with the minimum bounding box for the text.padding_*
: adds (positive numbers) or subtracts (negative numbers) this many pixels from the bounding box on the specified side (_top, _bottom, _left, _right)Special tips on BDF loaded fonts:
The text was updated successfully, but these errors were encountered: