Skip to content

Allow creating a Buffer with no FontSystem#127

Merged
jackpot51 merged 2 commits intopop-os:mainfrom
tigregalis:buffer-no-font-system
Jun 9, 2023
Merged

Allow creating a Buffer with no FontSystem#127
jackpot51 merged 2 commits intopop-os:mainfrom
tigregalis:buffer-no-font-system

Conversation

@tigregalis
Copy link
Copy Markdown
Contributor

Changes

This introduces a new constructor Buffer::new_empty which has zero BufferLines and is unshaped.

Buffer::new calls Buffer::new_empty.

Context

#97 untangled the Buffer from the FontSystem, but didn't remove the need to pass a FontSystem into Buffer::new.

It is useful to be able to initialise a Buffer when you don't have a FontSystem in scope, for example if you want to impl Default for some type that contains a Buffer, since it is otherwise constructable without a FontSystem:

let buffer = Buffer::new_empty(Metrics::new(MY_DEFAULT_FONT_SIZE, MY_DEFAULT_LINE_HEIGHT));

Future work

Any of the examples where Buffer::new is called and then immediately overwritten through Buffer::set_text or overwriting the BufferLines could be rewritten in terms of Buffer::new_empty but I have not done this.

jackpot51
jackpot51 previously approved these changes Jun 8, 2023
@jackpot51
Copy link
Copy Markdown
Member

This now has conflicts after #122

@tigregalis
Copy link
Copy Markdown
Contributor Author

I've resolved the conflict.

@jackpot51 jackpot51 merged commit b6b0358 into pop-os:main Jun 9, 2023
StewartCanva pushed a commit to StewartCanva/cosmic-text that referenced this pull request Jun 26, 2025
Allow creating a `Buffer` with no `FontSystem`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants