Unable to change font in BTextView


#1

Hi all,
this is my first time posting here.
I am Johannes from Germany. So pls apologize my bad english.
And i really love Haiku :slight_smile:

So… i’m about programming some software for Haiku.
While that, i’m struggled of lots of problems…
First of all, i tried to make my GUI with the Layout lib. Works bad.
Lots of graphic errors.
So i decided to make my GUI the old way :wink:
Works perfect… till now.

I have a BTextView and i wanna change the font size and color in there.
But it just dont work!

I even tried in a small project with just a BTextView…

MainWindow::MainWindow(void)
: BWindow(BRect(100,100,500,400),“Main Window”,B_TITLED_WINDOW, B_ASYNCHRONOUS_CONTROLS)
{
BRect r(Bounds());
r.bottom = 20;
fMenuBar = new BMenuBar(r,“menubar”);
AddChild(fMenuBar);
r = Bounds();
r.top = 20;

BTextView* fTextView = new BTextView(r,"textview",BRect(0,0,1000,1000),B_FOLLOW_ALL);

AddChild(fTextView);
BFont font;
fTextView->GetFont(&font);
font.SetFace(B_BOLD_FACE);
font.SetSpacing(B_CHAR_SPACING);
fTextView->SetFont(&font);

}

But it just dont work.

The font remains the same…


#2

BTextView uses a text_run_array structure to describe fonts and colors of the text.
You can modify the structure easily with:
https://www.haiku-os.org/legacy-docs/bebook/BTextView.html#BTextView_SetFontAndColor

I suggest to use layout or your application will not scale with different fonts.
(https://www.haiku-os.org/docs/api/layout_intro.html)


#3

Thanks for your answer. As i said, it tryed to us the Layout api. But it works not really good. I got lots of graphic failures. But it will try to test the text_run_array. Thx alot


#4

And i tryed SetFontAndColor many times in many ways… did not work…


#5

It would really help to see the code. Also of your layout management adventures. All apps coming with Haiku and many 3rd party apps are using it successfully, so there has to be something wrong with the code.
I suggest putting it into a github repo.


#6

Oh, I dont think its the libs fault.
It think i had faults in my code.
But yea, i decided to build my GUI the old way. Seems to that i have more control over it.

BTW i dont know how to put my code on git :wink:

Actually, i’m working on a IDE for Haiku. I dont think that Paladin is really usefull.


#7

I’d be surprised if there aren’t a few dozen tutorials and videos about that around… )

Paladin is under heavy development by @adamfowleruk currently. Give him a bit more time to squash the dozens of bugs he catalogued…


#8




#9

I’m a little surprised that there’s no “HaiCode”
Heidi is pretty close, though.


#10

Hooo… i will take a closer look to all of them. Mine is name HaIDE :wink:


#11

Well, paladin is great. But its not an IDE. So… i would be glad to see it as one.


#12

Some are admittedly old/unmaintained, with ideam being the most recently updated. Please consider contributing to these existing projects instead of starting from scratch :slight_smile:


#13

You are right KapiX, but there is always the… you know… to make something special. for your own. I know its ridicoulus… but hey… its a hobby for me… so as i said, i’ll take a look at the others and maybe, just maybe i can help a little bit.


#14

Sure, I get that. You might get there (making something special) faster starting with some foundation though :slight_smile:


#15

But im not really sure how got get in contact with those guys.
And i am shy to release my work. I know i can code, but i’m not that good as those
guys who wrote the Haiku Kernel.


#16

More than happy to take volunteers to mould Paladin. The version in Haiku Depot is quite old and buggy.

Please take a look at the milestones on Github for Paladin to see the ideas and options we’re playing with. Especially the Developer Work flow and UI Experiments milestones. Lots of interesting things there, and I’m more than happy to experiment with unique takes on things. No need for you to start from scratch.

Paladin should be ready for a 1.5 release that fixes all outstanding bugs in the next 3 weeks. Hoping to finish before BeGeistert in Hamburg. After that it’ll be around ease of development, template projects, and other things to make coding for Haiku easier. (E.g. A template window app with controls and layouts preconfigured and working!)

Please do consider lending a hand.


#17

You don’t have to be. Everyone was a beginner sometime. :slight_smile:
Releasing your work and have people more experienced look at it might even speed up your learning process.

Sending a Pull Request is a good way to do that.

If you want to get help wrt using git feel free to DM or email me directly. :slight_smile:

I can’t speak for AmosCaster, but waddlesplash is one of Haiku developers and HaikuArchives is a fairly active org where any PR is appreciated and will be looked at pretty soon.

I think the issue Samson has with Paladin is its multi-window GUI. I wouldn’t want to see that go, but it’s fine some people don’t like it.


#18

Yes, Paladins Multi Window is not what i like. An IDE for me is a, as it sais, integrated development environtment. So, all in one place. Its really enerving to switch throu tens of windows.


#19

THX to all. I was able to change Font and Color in the BTextView now. As always, it was a human
failure :wink:
THX for you help!


#20

That makes sense. Paladin currently uses an external editor. I am toying with the concept of saved Window Layouts that would be restored on opening a project. So all the editor windows would be reopened in their exact previous state and location. (May be useful to other apps, so I’d add this is a separate library).

I also need to look at the replicant code to see if it’s feasible to grab most of an application and embed it. E.g. A Pe editor window’s content within a Paladin Window. That would be a cheap way to get an IDE.