Skip to content
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

Degree sign doesn't get rendered #64

Open
BrainStone opened this issue Mar 27, 2018 · 6 comments
Open

Degree sign doesn't get rendered #64

BrainStone opened this issue Mar 27, 2018 · 6 comments

Comments

@BrainStone
Copy link

Whenever I try to render text containing the degree sign (°), everything after it isn't rendered anymore. What could be the cause of that?

@steverpi
Copy link

Could be same as when using micro symbol (mu) µ which is not 8-bit encoding. May work if you set localisation - just a suggestion:

#include <locale.h> // For use with multi-byte parsing routines (extended char sets other than 7-bit ascii) otherwise
// will return an empty string if you pass a string with a char val > 127
setlocale(LC_ALL, "") ; // Set locale for everything

@BrainStone
Copy link
Author

Hm. I already set an specify locale so special chars get rendered correctly. I'll see if I can get it working. But that's a great point to start.

@ajstarks
Copy link
Owner

That's odd. Are you using the C library or Go wrapper?

I have a specific app that uses the degree symbol, twh (https://github.com/ajstarks/openvg/blob/master/go-client/twh/twh.go)

@BrainStone
Copy link
Author

BrainStone commented Mar 27, 2018

@wasalm
Copy link

wasalm commented Apr 14, 2018

Turns out that the degree sign is not part of the Dejavusans font.
You need to find a font which contains the degree sign and turn it into c++ code with font2openvg.

If you are interested, I already compiled some weather symbols into c++.
It originated from weathericons.io (some may be reordered)
You can download it from http://www.andries-salm.com/weatherIcons.cpp

@ajstarks
Copy link
Owner

Degree is in indeed in the default font. This program:

// first OpenVG program
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include "VG/openvg.h"
#include "VG/vgu.h"
#include "fontinfo.h"
#include "shapes.h"

int main() {
	int width, height;
	char s[3];
	init(&width, &height);				   // Graphics initialization

	Start(width, height);				   // Start the picture
	Background(0, 0, 0);				   // Black background
	Fill(44, 77, 232, 1);				   // Big blue marble
	Circle(width / 2, 0, width);			   // The "world"
	Fill(255, 255, 255, 1);				   // White text

	TextMid(width / 2, (height * 0.7), "100 °C", SerifTypeface, width/15); 
	End();						   // End the picture

	fgets(s, 2, stdin);				   // look at the pic, end with [RETURN]
	finish();					   // Graphics cleanup
	exit(0);
}

degree

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

No branches or pull requests

4 participants