I'm working on implementing true type fonts in my program but there is a huge problem interpreting some data to the correct values from the glyph table.
I'm working with the windows specification (Link: https://www.microsoft.com/typography/otspec/glyf.html)
and in addition the apple specification (Link:
https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6glyf.html)
And in order to check the values I'm using this page:
(Link: https://opentype.js.org/glyph-inspector.html)
The font that I'm using is the raleway font - medium
(Link: https://www.fontsquirrel.com/fonts/raleway)
I can see that the values of numberOfContours, xMin, yMin, xMax, yMax and endpContour[0] are correct so far. I don't know about the instructionLength[0].
The example below is not the general code but the bytecode for the entry that I need to interpret correctly. The problem is that I can't get my head around the next values to fill. (instructionLength, flags...)
The character that is represented below is the acute. It is made of 4 points.
The expected result of the 4 points from that only one contour are:
p0: x=106, y=609
p1: x=48, y=629
p2: x=106, y=730
p3: x=194, y=730
additional information:
advanceWidth: 232
leftSideBearing: 48
(source: https://opentype.js.org/glyph-inspector.html)
In sum the arcute consists out of 50 bytes.
1. 0 | -> 0000 0000 | -> 1 | -> 0000 0000 0000 0001 | (ind. 0) <- numberOfContours
2. 1 | -> 0000 0001 | ^
3. 0 | -> 0000 0000 | -> 48 | -> 0000 0000 0011 0000 | (ind. 1) <- xMin
4. 48 | -> 0011 0000 | ^
5. 2 | -> 0000 0010 | -> 609 | -> 0000 0010 0110 0001 | (ind. 2) <- yMin
6. 97 | -> 0110 0001 | ^
7. 0 | -> 0000 0000 | -> 609 | -> 0000 0000 1100 0010 | (ind. 3) <- xMax
8. 194 | -> 1100 0010 | ^
9. 2 | -> 0000 0010 | -> 730 | -> 0000 0010 1101 1010 | (ind. 4) <- yMax
10. 218 | -> 1101 1010 | ^
11. 0 | -> 0000 0000 | -> 3 | -> 0000 0000 0000 0011 | (ind. 5) <- endpContour[0]
12. 3 | -> 0000 0011 | ^
13. 0 | -> 0000 0000 | -> 23 | -> 0000 0000 0001 0111 | (ind. 6) <- instructionLength[0]
14. 23 | -> 0001 0111
15. 177 | -> 1011 0001
16. 6 | -> 0000 0110
17. 100 | -> 0110 0100
18. 68 | -> 0100 0100
19. 64 | -> 0100 0000
20. 12 | -> 0000 1100
21. 1 | -> 0000 0001
22. 1 | -> 0000 0001
23. 0 | -> 0000 0000
24. 71 | -> 0100 0111
25. 0 | -> 0000 0000
26. 0 | -> 0000 0000
27. 0 | -> 0000 0000
28. 116 | -> 0111 0100
29. 18 | -> 0001 0010
30. 1 | -> 0000 0001
31. 9 | -> 0000 1001
32. 21 | -> 0001 0101
33. 43 | -> 0010 1011
34. 177 | -> 1011 0001
35. 6 | -> 0000 0110
36. 0 | -> 0000 0000
37. 68 | -> 0100 0100
38. 19 | -> 0001 0011
39. 39 | -> 0010 0111
40. 55 | -> 0011 0111
41. 51 | -> 0011 0011
42. 106 | -> 0110 1010
43. 58 | -> 0011 1010
44. 58 | -> 0011 1010
45. 88 | -> 0101 1000
46. 2 | -> 0000 0010
47. 97 | -> 0110 0001
48. 20 | -> 0001 0100
49. 101 | -> 0110 0101
50. 0 | -> 0000 0000
I need to know from you how the get the instructionLegths and it's values correct and what it is used for (couldn't find something about that in the docs.) the flags and the points I mentioned above.
Thank you in advance!
Related
I am new to psql. I have a table of car ids - id and their battery level - battery at every ten-minute interval for 2 weeks.
My goal is to create an output of the total count of unique car ids whose batteries experienced any gain per day. That could mean that at any time over the course of the day where a car's battery level was higher than the previous time stamp. In other words, where the value of battery - the previous value of battery is positive. Records with NA values under battery should be skipped.
I have started with the query but I am unsure how to only select unique id's whose battery levels rose. Any recommendations would be appreciated!
SELECT count(distinct id), TO_CHAR(date_trunc('day', (time::timestamp) AT TIME ZONE 'EST'), 'YYYY-MM-DD') AS day FROM test_db ....
GROUP by day
ORDER by day
Here is a sample of the data :
id| time| battery
54 | 2017-12-12 09:50:04.402775+00 | 100
54 | 2017-12-12 09:40:04.618926+00 | 100
54 | 2017-12-12 09:30:04.11399+00 | 100
54 | 2017-12-12 09:20:03.906716+00 | 100
54 | 2017-12-12 09:10:03.955133+00 | 100
54 | 2017-12-12 09:00:04.678508+00 | 100
54 | 2017-12-12 08:50:03.733471+00 | 100
54 | 2017-12-12 08:40:03.65688+00 | 100
54 | 2017-12-12 08:30:04.260608+00 | 100
54 | 2017-12-12 08:20:03.98387+00 | 100
54 | 2017-12-12 08:10:04.164129+00 | 98
54 | 2017-12-12 08:00:04.597976+00 | 98
54 | 2017-12-12 07:50:04.501231+00 | 98
54 | 2017-12-12 07:40:04.441531+00 | 98
54 | 2017-12-12 07:30:04.310876+00 | 98
54 | 2017-12-12 07:20:04.317241+00 | 98
54 | 2017-12-12 07:10:03.856432+00 | 67
54 | 2017-12-12 07:00:03.628862+00 | 67
54 | 2017-12-12 06:50:03.868495+00 | 67
54 | 2017-12-12 06:40:04.490324+00 | 67
54 | 2017-12-12 06:30:03.83739+00 | 67
54 | 2017-12-12 06:20:03.817014+00 | 67
54 | 2017-12-12 06:10:04.081174+00 | 29
54 | 2017-12-12 06:00:04.178765+00 | 29
data_type
--------------------------
integer
timestamp with time zone
integer
I am writing an sql query to display names of guests who have incurred both athletic and dinner charges on their itinerary. Can someone point me in the right direction as to setting up the query?
this is what i have but gives no result..
SELECT GUEST.FIRSTNAME, CHARGETYPE.DESCRIPTION
FROM GUEST, CHARGES, CHARGETYPE
WHERE CHARGETYPE.CHARGEID = CHARGES.CHARGEID
AND CHARGES.CHARGEID = '07'
AND CHARGES.CHARGEID = '03'
the chargeid 07 and 03 reflect athletic and dinner charges respectfully. im sorry for the lack of info, first time really using stackoverflow.
Here is the CHARGETYPE table
CHARGEID and DESCRIPTION are the column names
01 ROOM DEPOSIT
02 LUNCH SERVICE
03 DINNER SERVICE
04 BREAKFAST SERVICE
05 ROOM CHARGE
06 GIFTSHOP PURCHASE
07 ATHLETIC CHARGE
CHARGEID, ITINID, CHARGETIME, AMOUNT, GUESTID are the columns for the CHARGES table
01 001 11:00 -1850001
02 001 14:00 30 0001
03 001 18:00 55 0001
04 001 11:00 20 0001
05 001 20:00 20 0001
08 001 12:00 20 0001
01 002 16:00 -185 0002
02 002 16:30 40 0002
04 002 10:00 20 0002
05 002 14:00 25 0002
09 002 15:00 25 0002
01 003 10:00 -185 0003
02 003 12:00 30 0003
03 003 18:00 50 0003
04 003 11:00 18 0003
05 003 12:30 27 0003
06 003 14:45 30 0003
01 004 11:00 -185 0004
02 004 13:00 40 0004
03 004 19:00 60 0004
04 004 11:00 15 0004
05 004 20:00 34 0004
01 005 10:00 -185 0005
02 005 12:00 30 0005
03 005 17:00 30 0005
04 005 10:00 10 0005
05 005 16:00 25 0005
01 006 11:00 -185 0001
02 006 12:00 22 0001
03 006 18:00 40 0001
04 006 08:00 15 0001
05 006 20:00 60 0001
07 006 14:00 50 0001
01 007 11:00 -185 0003
02 007 12:00 20 0003
03 007 17:00 55 0003
04 007 10:00 15 0003
05 007 16:00 45 0003
01 008 11:00 -185 0005
02 008 13:00 20 0005
03 008 18:00 60 0005
04 008 09:00 20 0005
05 008 22:00 65 0005
07 008 12:00 50 0005
.
GUESTID LASTNAME FIRSTNAME are the columns for the GUEST table
0001 SMITH JOHN
0002 SMITH LISA
0003 ADAMS PETER
0004 ADAMS JANE
0005 JOHNSON DEAN
SELECT G.FIRSTNAME,G.LASTNAME, CT.DESCRIPTION
FROM GUEST G
INNER JOIN CHARGETYPE CT
ON G.GUESTID = C.GUESTID
INNER JOIN CHARGES
ON CT.CHARGEID = C.CHARGEID
WHERE C.CHARGEID IN ('07','03' );
I would like to replicate key names x number of times and have a separate column to indicate the replication number, e.g. let's say I have three key names as follows:
101
102
103
So, I would like each of the above numbers (names) replicated 3 times and to have a separate identifier number equal to 4 characters. It would therefore look like this:
101 0001
101 0002
101 0003
102 0001
102 0002
102 0003
103 0001
103 0002
103 0003
I guess this could be genered with a relatively straight forward awk script? *Edit: I would like to not specify the names to replicate in the script - it should be "replicate all names in this text file", as there are a lot of them (~400) and all with variable name types.
Thank you in advance!
In bash
echo {101,102,103}" "{01,02,03}
101 01 101 02 101 03 102 01 102 02 102 03 103 01 103 02 103 03
Following Fedorqui's advice for newlines
printf "%s\n" {101,102,103}" "{01,02,03}
101 01
101 02
101 03
102 01
102 02
102 03
103 01
103 02
103 03
Using the awk -v flag to pass a variable number which is the number of repeats for each line, and sprint to format the number into 2 decimal places with zero padding:
awk -v number_repeats=3 '{
for(i=0; i<number_repeats; i++) {
print $0, sprintf("%02d", i+1)
}
}'
If you don't mind GNU Parallel
parallel -k 'printf "%02d %02d\n"' ::: {6..12} ::: 1 2 3
06 01
06 02
06 03
07 01
07 02
07 03
08 01
08 02
08 03
09 01
09 02
09 03
10 01
10 02
10 03
11 01
11 02
11 03
12 01
12 02
12 03
Or, if your keys are in a file, called keys like this
32
45
78
You can read the file
parallel -k 'printf "%02d %02d\n" {1} {2}' :::: keys ::: 1 2 3
32 01
32 02
32 03
45 01
45 02
45 03
78 01
78 02
78 03
I have to fill in the blanks for a 2 4mb RAM chip and 2 64kb ROM chip. I don't understand how to do it. Any type of input on it would help.
| Starting Address (Binary) | Starting Add. (Hex)| Ending Add. (Hex)|
4mb RAM1 | 0000 0000 0000 0000 0000 0000 | 00 00 00 | |
4mb RAM2 | | | |
-------------------------------------------------------------------------------------
64kbROM1 | 1010 0000 0000 0000 0000 0000 | A0 00 00 | |
64kbROM2 | | | |
I think that for RAM 1 the ending address is FF FF FF. But I do not know where to start with the next starting binary address.
OK - this is really just simple arithmetic with hex and binary. I'll get you started - see if you can fill in the rest...
| Starting Address (Binary) | Starting Add. (Hex)| Ending Add. (Hex)|
4MB RAM1 | 0000 0000 0000 0000 0000 0000 | 00 00 00 | 3F FF FF |
4MB RAM2 | 0100 0000 0000 0000 0000 0000 | 40 00 00 | |
------------------------------------------------------------------------------------
64kB ROM1 | 1010 0000 0000 0000 0000 0000 | A0 00 00 | |
64kB ROM2 | | | |
A useful quantity to remember is 1 MB == 100000 in hexadecimal.
Also note that the unit for byte is B (upper case), mega is M (upper case) and kilo is k (lower case). So it's kB for kilobytes, and MB for megabytes. If you think this is pedantic then note that lower case m means "milli", which is 1/1000th of a unit - I doubt that your system has 4 millibyte RAM modules!
I have this structure of table
-----------------------------------------------------------------
ID-Prod | Monday | Tuesday | Wednesday | Thursday | Friday |....
-----------------------------------------------------------------
012 213 879 516 213 435
013 953 837 361 862
014 123 583 879 519 573
015 963
016 798
ID-Prod is the primary key, i would like to sum all the values for each product
for example
---------------------------------------------------------------------------------------
ID-Prod | Monday | Tuesday | Wednesday | Thursday | Friday |....| Total
---------------------------------------------------------------------------------------
012 213 879 516 213 435 213+879+516+213+435
013 953 837 361 862 .....
014 123 583 879 519 573 .....
015 963
016 798
Thanks
SELECT t.*,
COALESCE(Monday, 0) +
COALESCE(Tuesday, 0) +
COALESCE(Wednesday, 0) +
COALESCE(Thursday, 0) +
COALESCE(Friday, 0) AS total
FROM mytable t