Comments (8)
I was able to tinker with this for a bit tonight. I think we can use the font
property and test against terminalio.FONT
. This example seems to print the correct value for both types of fonts:
import board
import terminalio
from adafruit_display_text import label
from adafruit_bitmap_font import bitmap_font
#font = bitmap_font.load_font("/Helvetica-Bold-16.bdf")
font = terminalio.FONT
text = "Hello world"
text_area = label.Label(font, text=text)
text_area.x = 10
text_area.y = 10
board.DISPLAY.show(text_area)
print(text_area.font == terminalio.FONT)
while True:
pass
from adafruit_circuitpython_display_text.
Thank you for sharing that example code Kevin! I am trying to put together a suite of tests to run whenever display_text is updated, I will add this one.
I am assuming the performance hit is due creating the bitmap and tilegrids, if so, I think we are likely stuck with it at least for custom fonts, since the bitmap is required to make the background look correct.
Something we could look into is adding logic that will revert to the previous background strategy when the default font is used instead of the newer bitmap+tilegrid. I think that should get the performance back to how it was for default font labels.
from adafruit_circuitpython_display_text.
Agreed on your comment about treating the builtin font differently. However when I first looked into it I couldn’t figure out how to detect which font type (builtin vs BDF lodes). I think that is the key to unlocking the ability to treat each differently.
from adafruit_circuitpython_display_text.
Looks like good progress. To me it’s a little odd that there is a separate class for type BuiltInFont https://circuitpython.readthedocs.io/en/5.3.x/shared-bindings/fontio/BuiltinFont.html
Does anyone know if there will ever be more BuiltInFont
other than terminalio.FONT? If so does this need to be generic for all BuiltInFonts?
My guess is that your code will most cases but wanted to document this here.
from adafruit_circuitpython_display_text.
That is a good question. I don't know whether there will ever be others. I do think that some devices have a different built-in font, but it's still referenced with terminalio.FONT
I think.
Just in case we could make this a little more generic by checking the type like this:
print(isinstance(text_area.font, fontio.BuiltinFont))
This one seems to be working as well when substituted in the above example.
from adafruit_circuitpython_display_text.
Some feedback from @tannewt regarding display performance here:
#71
from adafruit_circuitpython_display_text.
BuiltInFont exists to make it easier to build in a font. If it was python, then it'd be trickier to have the object within the core build itself. It's mean to have the same API as other font classes and be treated the same.
I wouldn't expect more than one to exist in a build because they take a good chunk of space.
from adafruit_circuitpython_display_text.
The original issue that was linked was closed, so closing this issue also.
from adafruit_circuitpython_display_text.
Related Issues (20)
- save_text=False throws error on init HOT 11
- Missing Type Annotations HOT 1
- Spaces are deleted when word-wrapping HOT 1
- Updates to text are inefficient for special case of same length and width text HOT 3
- bitmap_label losing direction HOT 6
- Suppress warnings in bitmap_label HOT 1
- Use `fontio.FontProtocol` for type annotations
- Label can take Tuple[int, int, int] for color HOT 1
- wrap_text_to_pixels() cannot handle Windows line endings HOT 1
- bitmap_label flicker HOT 1
- Unable to update scrolling_label text outside constructor HOT 2
- Exception with multiple consecutive newlines in bitmap label
- label.Label padding is wrong when using DWR or UPR HOT 5
- button simpletest throws error on PyPortal Titano HOT 1
- bitmap_label errors if no bitmaptools module present
- ValueError from negatives on first character
- Convert `.show()` to `.root_group =` for CircuitPython 9
- Program stops without any error when importing the library HOT 4
- bitmap label cuts off part of text HOT 3
- Add error handling for misspelled kwargs in adafruit_display_text.label HOT 4
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 adafruit_circuitpython_display_text.