Search the Community
Showing results for tags 'text'.
-
Hello again. Implemented UTF8 support for LE4. Works fine?. context->SetBlendMode(Blend::Alpha); context->DrawText(u8"Привет мир! Hello world!", 25.0f, 25.0f); context->SetBlendMode(Blend::Solid); Add yours symbols to "familychars" and make own "family" in Font.cpp if (family==Font::English) { familychars = L"abcdefghijklmnopqrstuvwxyzабвгдеёжзийклмнопрстуфхцчшщъыьэюя АБВГДЕЁЖЗИКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890-=!@#$%^&*()_+[]\\{}|;':\",./<>? `~"; } Update: #include <codecvt> std::string WideStringToString(const std::wstring & str) { std::wstring_convert<std::codecvt_utf8<wchar_t>> myconv; return myconv.to_bytes(str); } std::wstring StringToWideString(const std::string & str) { std::wstring_convert<std::codecvt_utf8<wchar_t>> convert; return convert.from_bytes(str); } Gud luck?️! FontSrc.zip
-
Hi I have a small problem. I think the pictures should explain it pretty good With font size of 12 see the terrible cut on the top?: With font size 20 it is a little bit better but somehow not as sharp as it should be; This is how I would expect it to look like: I am rendering the text with the default arial.ttf font, I render the following color Vec4(0, 0, 0, 255) and with blendmode Blend.Alpha. So whats the problem? I remember the text rendered sharper another time, but I dont know what I am doing wrong atm? Any suggestions?
-
I'm not sure what has happened, but I noticed that text, that used to bee nice to look at and clear, is now somehow bugged. Here is example pic attached. You notice that in "Switch" (at the center of the screen) letters are not in line and spaces between them are not even. It looks generally bad. It was not like this before. What did I do?
-
I want to make a password pad to put in some numbers. The attached picture is what it looks now, at a resolution of 1080 p. (for 1920 p the green text fits in properly) But as you can see the text is not scaled with the window, so how do I make it right? I can get the top left and bottom right of the screen as x,y vectors, but how do i calculate that the text always is inside of it ?
-
A long time ago I had this problem with text overlapping itself when you used some entities in the game, then Rick (thanks by the way) came along and fixed this issue. This is the code right now: Inside FPSPlayer.lua right below the default variables: Script.DisplayTimeMax = 4000 local font1 = Font:Load("Fonts/MODERN SERIF ERODED.ttf", 20) In the Start(): self.text = "" Inside the UpdateWorld() if pickInfo.entity ~= nil then if pickInfo.entity.script ~= nil then if pickInfo.entity.script.GetText ~= nil then self.text = pickInfo.entity.script:GetText() self.DisplayTime = Time:GetCurrent() + self.DisplayTimeMax end end end Under PostRender(context) if self.text ~= "" then context:SetBlendMode(Blend.Alpha) context:SetFont(font1) if self.DisplayTime > Time:GetCurrent() then context:SetColor(255,255,255) context:DrawText(self.text, 100, 600) else -- reset self.text = "" end end This is all that was required (back in 2015) to set up the player script, then we had this simple code for the entities: Script.ObjectDescription = "" --string "Object Description" function Script:GetText() return self.ObjectDescription end function Script:Disable()--in self.enabled=false end Now the only problem here is that the hand icon doesn't actually show up, so the player can't interact with it, I tried doing a Use(context) function that called the self.GetText() but that just caused the game to exit out with an error saying: Script Error attempt to index local 'self' (a nil value) Line 8 So any thoughts as to how I would resolve this issue?
- 4 replies
-
- Text
- Interaction
-
(and 1 more)
Tagged with:
-
It looks like DrawText doesn't like multi-line string literals, it's reading them in as one long line that ends up mostly off of the screen and doesn't respond to escape characters (such as "\n") embedded in the multi-line string in order to try and simulate "wrapping". Either I'm missing some undocumented param or DrawText was only meant to draw a single line of text at a time. Of course, I can write a loop for this, but that incurs a performance penalty, especially with longer bits of text and seems to be a needlessly complex solution. My suggestion is to allow DrawText the ability to handle multi-line strings in LUA or have it renamed to DrawSingleLineText, since that's what it does.
-
So a while ago, I got this script going that makes so the player presses E text will show up, my problem is, if the player clicks on 2 objects at the same time, the text will overlap itself Script Script.ObjectDescription = "" --String "Object Description" Script.DisplayTimeMax = 5000 --Int "Display time" Script.Used = "0" Script.DisplayTime = 0 Script.DisplayEnabled = false local font1 = Font:Load("Fonts/True Lies.ttf", 20) function Script:Use(context) self.Used = "1" self.CurrentTime = Time:GetCurrent() self.DisplayTime = Time:GetCurrent() + self.DisplayTimeMax end function Script:PostRender(context) if self.Used == "1" then App.context:SetBlendMode(Blend.Alpha) App.context:SetFont(font1) self.DisplayEnabled = true if self.DisplayEnabled == true then if self.DisplayTime > Time:GetCurrent() then App.context:SetColor(255,255,255) context:DrawText(self.ObjectDescription, 100, 600) else self.DisplayEnabled = false self.Used = "0" end end App.context:SetBlendMode(Blend.Solid) end end And my problem